/**
 * 具名返回保存的cookie值
 * @param name 需要返回的cookies名
 * @returns cookie
 */
export function getCookies(name:string){
    let arr = document.cookie.split(";")
    let arrMap:Map<string,string> = new Map()
    if (arr.length <= 3) return
    arr.forEach(el => {
        let keyValue = el.split("=")
        arrMap.set(keyValue[0].trim(),keyValue[1].trim())
    })
    return arrMap.get(name)
}
/**
 * 
 * @param arr 包含用户信息的cookie格式 xx=xxx
 */
export function setCookies(arr:Array<string>) {
    let Expires = new Date().getTime()
    arr.forEach(el => {
        document.cookie = el + ";expires="+new Date(Expires*1000)
    })
}
/**
 * 删除所有cookie
 */
export function remove(){
    let arr = document.cookie.split(';')
    arr.forEach(el => {
        document.cookie = el + ';expires='+new Date(0) +';path=/'
    })
}